/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package simplemetrosystem.view.menu;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import simplemetrosystem.model.charlanguage.NameMap;
import simplemetrosystem.view.MetroFrame;
import simplemetrosystem.view.canvas.MetroCanvas;

/**
 *
 * @author Eric Qian
 */
public class DisplayMenu extends JMenu {

    public DisplayMenu(MetroFrame frame) {
        this.frame = frame;
        nameMap = NameMap.getInstance();
        this.setText(nameMap.getName("Display"));
        init();
    }

    private void init() {
        this.add(getDisplayMatrixItem());
        this.add(getDisplayStationNameItem());
    }

    public JMenuItem getDisplayMatrixItem() {
        if (dmItem == null) {
            dmItem = new JMenuItem();
            dmItem.setText(nameMap.getName("Display Matrix"));
            dmItem.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    MetroCanvas metro = frame.getMetroTabbedPane().getAllLineCanvas();
                    metro.setMatrix(!metro.getMatrix());
                }
            });

        }
        return dmItem;
    }

    public JMenuItem getDisplayStationNameItem() {
        if (dsnItem == null) {
            dsnItem = new JMenuItem();
            dsnItem.setText(nameMap.getName("Display Station Name"));
            dsnItem.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    throw new UnsupportedOperationException("Not supported yet.");
                }
            });
        }
        return dsnItem;
    }
    private MetroFrame frame;
    private NameMap nameMap;
    private JMenuItem dmItem;
    private JMenuItem dsnItem;
}
